/**
 * loads content for editor and initializes editor object
 * @param url
 * @return
 */
function loadEditor(url){
	$('#content').html('<img src="./admin/images/loading.gif" alt="loading..." />');
	$.get('./website/' + url, function(response){
			$('#content').html('<textarea class="jquery_ckeditor" cols="80" rows="10">' + response + '</textarea>');
			var config = {
					height: '500px'
			};
			$('.jquery_ckeditor').ckeditor(config);
	});
}

/**
 * sets all infos for cms module and loads the editor
 */
function setCMSInfo(file){
	loadEditor(file);
	pageSettings.saveInfo.moduleInfo.name = 'CMS'; 
	pageSettings.saveInfo.moduleInfo.file = file;
}


function saveHtmlFile(){
	var content = $('#content textarea.jquery_ckeditor').val();
	var params = getEncodedParams({'FILE':pageSettings.saveInfo.moduleInfo.file, 'CONTENT':content});
	$.ajax({
		url: loadCMSUrl,
		type: 'POST',
		dataType: 'json',
		data: params,
		success: function(response){
			if (response.SUCCESS == 1)
				setStatus('Datei aktualisiert');
			else
				setStatus(response.ERROR_MSG, true);;	
		}
	});
}